<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	
	<script src="js/jquery-1.10.2.js"></script>
	<script src="js/jquery-ui-1.10.3.js"></script>
  	<script src="js/bootstrap.js"></script>
		
    <!-- Le styles -->
    <link href="css/bootstrap.css" rel="stylesheet">    
    <link href="css/bootstrap-responsive.css" rel="stylesheet">
	<link href="css/bootswatch.css" rel="stylesheet">
    <link href="css/jquery-ui-1.10.3.css" rel="stylesheet">
    
	<title>Karaoke</title>
</head>
<body>	
	
				<!-- INICIO DEL MENU PRINCIPAL -->
	    <div class="navbar navbar-inverse navbar-fixed-top">
	      <div class="navbar-inner">
	        <div class="container">
	          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
	            <span class="icon-bar"></span>
	            <span class="icon-bar"></span>
	            <span class="icon-bar"></span>
	          </a>
	          <a class="brand" href="#">Karaoke</a>
	          <div class="nav-collapse collapse">
	            <ul class="nav">
	            <ul class="nav">
	              <li class="active"><a href="#">Home</a></li>
	              <li><a href="ReservaBuscar.jsp">Reservas</a></li>
	              <li><a href="ProductoBuscar.jsp">Productos</a></li>
	              <li><a href="LocalBuscar.jsp">Locales</a></li>
	              <li><a href="SalaBuscar.jsp">Salas</a></li>
	              <li><a href="EventoBuscar.jsp">Eventos</a></li>
	              <li><a href="ComprobanteBuscar.jsp">Comprobante</a></li>
	            </ul>
	          </div>
	        </div>
	      </div>
	    </div>
		<!-- FIN DEL MENU PRINCIPAL -->

	<div>	
		<br>
		<br>
		<br>
		
	
		<fieldset class="form-horizontal well">
		
			<%@page import="java.util.*, pe.edu.upc.karaoke.modelo.*" %>
			
			<h3>Generar Comprobante</h3>

				<form id="form1" name="form1" method="post" action="ComprobanteServlet?Param=agregar">	
					Producto:
					<%
					List<Producto> listaProduto = (ArrayList<Producto>)request.getAttribute("productos");
					if(listaProduto != null) { 
					int i = 1;
					%>
					<select name="listaProducto" id="listaProducto">
						<%for(Producto x : listaProduto) {%>  
						  <option value=<%out.print(x.getIdProducto());%>><%out.print(x.getNombre());%></option>
						<% } %> 
					</select>
					<% } %>
				 			 	
					Cantidad: <input id="txtCantidad" name="txtCantidad" type="text" required autofocus/>
				
			 		<button id="button" type="submit" class="btn btn-primary">Agregar</button>
			 	</form>
		</fieldset>
		
		<fieldset>  		
			<form id="form2" name="form2" method="post" action=ComprobanteServlet?Param=insertar>	
			<table class="table table-striped table-bordered">
		
				<tr>
				  <th width="10" scope="col">Nro.</th>
				  <th width="50" scope="col">Producto</th>
				  <th width="20" scope="col">Precio</th>
				  <th width="20" scope="col">Cantidad</th>
				  <th width="20" scope="col">Sub Total</th>
				</tr>
			
				<%@page import="java.util.*, pe.edu.upc.karaoke.modelo.*" %>
				
				<%List<ComprobanteDetalle> listaComprobanteDetalle = (ArrayList<ComprobanteDetalle>)request.getAttribute("productoDetalle");	
				if(listaComprobanteDetalle != null) { 
				int i = 1;
					for(ComprobanteDetalle x : listaComprobanteDetalle) {
				%>  
				  <tr>
				    <td><%=i++ %></td>
				    <td><% out.print(x.getProducto().getNombre()); %></td>
				    <td><% out.print(x.getProducto().getPrecio()); %></td>
				    <td><% out.print(x.getCantidad()); %></td>
				    <td><% out.print(x.getCantidad()*x.getProducto().getPrecio()); %></td>
				  </tr>
				<%  }  
				} %>
			  
			</table>
			
			Monto Total:	<input id="txtMonto" name="txtMonto" type="text" value = "<%=request.getAttribute("montoTotal")%>" readonly="readonly" />
			<br/> 
						
			Cajero:
			<%
			List<Cajero> lista = (ArrayList<Cajero>)request.getAttribute("cajeros");
			if(lista != null) { 
			int i = 1;
			%>
			<select name="listaCajero" id="listaCajero">
				<%for(Cajero x : lista) {%>  
				  <option value=<%out.print(x.getIdCajero());%>><%out.print(x.getNombre());%></option>
				<% } %> 
			</select>
			<% } %>
	  		<br/>
	  		<p/>&nbsp;
	  		
	  	  <button id="button" type="submit" class="btn btn-primary">Grabar</button>
	  	  		
		</form>		
	  </fieldset>  	
	
	  

			
	
	</div>
	
</body>
</html>